<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Abstractfront extends CI_Controller
{
    
    public function __construct() {
        parent::__construct();
        session_start();
        $this->load->model('Usermodel');
    }
    //返回
    public static function json($data) {
        if(is_array($data)) {
            return exit(json_encode($data));
        }
    }
    
    //判断是否登陆
    public function isLogin() {
        if (isset($_COOKIE["token"])) {
            $token=$_COOKIE["token"];
            $user=$this->Usermodel->getByToken($_COOKIE['token']);
            if($user){
                    return ;
            }
        }
        redirect('/login/index');
    }

    public function getHost(){
        if (isset($_COOKIE["token"]))
        {
            $user=$this->Usermodel->getByToken($_COOKIE['token']);
            if($user){
                return $user;
            }else{
                redirect('/login/index');
            }
        }else{
                redirect('/login/index');
        }
       
    }


 
}